package com.jml.责任链模式.企业分控系统.respon.handler.factory;


import com.jml.责任链模式.企业分控系统.respon.handler.impl.BlacklistHandler;
import com.jml.责任链模式.企业分控系统.respon.handler.impl.CurrentLimitHandler;
import com.jml.责任链模式.企业分控系统.respon.handler.impl.TokenHandler;

public class FactoryHandler {


    public static CurrentLimitHandler getCurrentLimitHandler() {
        return new CurrentLimitHandler(new BlacklistHandler(new TokenHandler(null)));
    }

    public static CurrentLimitHandler getCurrentLimitHandler2() {
        CurrentLimitHandler currentLimitHandler = new CurrentLimitHandler();
        BlacklistHandler blacklistHandler = new BlacklistHandler();
        //ip限流指向下一个next 黑名单
        currentLimitHandler.setNextGatewayHandler(blacklistHandler);
        // 黑名单next token
        blacklistHandler.setNextGatewayHandler(new TokenHandler());
        return currentLimitHandler;
    }

    public static void main(String[] args) {
        CurrentLimitHandler currentLimitHandler = FactoryHandler.getCurrentLimitHandler2();
        currentLimitHandler.doService();
    }
}
